home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / Hack / MISC / TERM-F~1.ZIP / TERM-F~1.HTM
Encoding:
Text File  |  1996-11-19  |  7.6 KB  |  194 lines

  1. ** HOWTO: Using Term to Pierce an Internet Firewall
  2.  
  3.  
  4. * Disclaimer * <------- !!! READ THIS IMPORTANT SECTION !!!
  5.  
  6. I hereby disclaim all responsibility for this hack.  If it backfires
  7. on you in any way whatsoever, that's the breaks.  Not my fault.  If
  8. you don't understand the risks inherent in doing this, don't do it.
  9. If you use this hack and it allows vicious hackers to break into your
  10. company's computers and costs you your job and your company millions
  11. of dollars, well that's just tough nuggies.  Don't come crying to me.
  12.  
  13.  
  14. * Author
  15.  
  16. This HOWTO-term-firewall file was written by
  17. Barak Pearlmutter <bap@learning.scr.siemens.com>
  18. *who disclaims all responsibility for it!*
  19.  
  20.  
  21. * Copyright
  22.  
  23. This document is released under the GPL.  This basically means you may
  24. copy and modify it at will, but may not prevent others from doing so.
  25.  
  26.  
  27. * Introduction
  28.  
  29. The term program is normally used over a modem or serial line, to
  30. allow various host-to-host services to flow along this simple serial
  31. connection.  However, sometimes it is useful to establish a term
  32. connection between two machines that communicate via telnet.  The most
  33. interesting instance of this is for connecting two hosts which are
  34. separated by ethernet firewalls or SOCKS servers.  Such firewalls
  35. provides facilities for establishing a telnet connection through the
  36. firewall, typically by using the SOCKS protocol to allow inside
  37. machines to get connections out, and requiring outside users to telnet
  38. first to a gateway machine which requires a one-time password.  These
  39. firewalls make it impossible to, for instance, have X clients on an
  40. inside machine communicate with an X server on an outside machine.
  41. But, by setting up a term connection, these restrictions can all be
  42. bypassed quite conveniently, at the user level.
  43.  
  44.  
  45. * The basic procedure
  46.  
  47. Setting up a term connection over a telnet substrate is a two-phase
  48. process.  First your usual telnet client is used to set up a telnet
  49. connection and log in.  Next, the telnet client is paused and control
  50. of the established telnet connection is given to term.
  51.  
  52.  
  53. * Detailed directions
  54.  
  55. In detail, the process goes like this.
  56.  
  57. First, from a machine inside the firewall, telnet to a target machine
  58. outside the firewall and log in.
  59.  
  60. Unless you are under linux and will be using the proc filesystem (see
  61. below) make sure your shell is an sh style shell.  Ie if your default
  62. shell is a csh variant, invoke telnet by
  63.  
  64. (setenv SHELL /bin/sh; telnet machine.outside)
  65.  
  66. After logging in, on the remote (outside) machine invoke the command
  67.  
  68.     term -r -n off telnet
  69.  
  70. Now break back to the telnet prompt on the local (inside) machine,
  71. using ^] or whatever, and use the telnet shell escape command ! to
  72. invoke term,
  73.  
  74.     telnet> ! term -n on telnet <&3 >&3
  75.  
  76. E voila!!!
  77.  
  78. (If you have a variant telnet, you might have to use some other file
  79. descriptor than 3; easy to check using trace.  But three seems to work
  80. on all bsd descendent telnet clients I've tried, under both sunon 4.x
  81. and the usual linux distributions.)
  82.  
  83. Alternatively, under linux you can pause the telnet with ^]^z, figure
  84. out its pid, and invoke
  85.  
  86.     term -n on -v /proc/<telnetpid>/fd/3 telnet
  87.  
  88.  
  89. * Multiple term sockets
  90.  
  91. It is a good idea to give the term socket an explicit name.  This is
  92. the "telnet" argument in the invocations of term above.  Unless you
  93. have the TERMSERVER environment variable set to telnet as appropriate,
  94. you invoke term clients with the -t switch, eg "trsh -t telnet".
  95.  
  96.  
  97. * The .term/termrc.telnet init file
  98.  
  99. I have checked line clarity using linecheck over this medium.  I
  100. expected it to be completely transparent, but it is not.  However, the
  101. only bad character seems to be 255.  The ~/.term/termrc.telnet I use
  102. (the .telnet is the name of the term connection, see above) contains:
  103.  
  104.     baudrate off
  105.     escape 255
  106.     ignore 255
  107.     timeout 600
  108.  
  109. Perhaps it could be improved by diddling, I am getting a throughput of
  110. only about 30k cps over a long-haul connection through a slow
  111. firewall.  Ftp can move about 100k cps over the same route.  A
  112. realistic baudrate might avoid some timeouts.
  113.  
  114.  
  115.  
  116. * Direction
  117.  
  118. Obviously, if you are starting from outside the firewall and zitching
  119. in using a SecureID card or something, you will want to reverse the
  120. roles of the remote vs local servers given above.  (If you don't
  121. understand what this means, perhaps you are not familiar enough with
  122. term to use the trick described in this file responsibly.)
  123.  
  124.  
  125. * Security
  126.  
  127. This is not much more of a vulnerability than the current possibility
  128. of having a telnet connection hijacked on an unsecured outside
  129. machine.  The primary additional risk comes from people being able to
  130. use the term socket you set up without you even being aware of it.  So
  131. be careful out there.  (Personally, I do this with an outside machine
  132. I know to be pretty secure, namely a linux laptop I maintain myself
  133. that does not accept any incoming connections.)
  134.  
  135.  
  136. * Telnet mode
  137.  
  138. Be sure the remote telnetd is not in some nasty seven-bit mode.  Or if
  139. it is, you have to tell term about it when you invoke term, by adding
  140. the -a switch at both ends.  (I sometimes use "^] telnet> set outbin"
  141. or "set bin" or invoke telnet with a -8 switch to put the connection
  142. into eight-bit mode.)
  143.  
  144.  
  145. * Bugs and term wish list
  146.  
  147. The linecheck program has some problems checking telnet connections
  148. sometimes.  This is sometimes because it doesn't check the return code
  149. of the read() call it makes.  For network connections, this call to
  150. read() can return -1 with an EINTR (interrupted) or EAGAIN (try again)
  151. error code.  Obviously this should be checked for.
  152.  
  153. There are a number of features that could ease the use of term over
  154. telnet.  These primarily relate to an assumption that influenced the
  155. design of term, namely that the connection is low bandwidth, low
  156. latency, and somewhat noisy.
  157.  
  158. A telnet connection is in general high bandwidth, high latency, and
  159. error free.  This means that the connection could be better utilized
  160. if (a) the maximum window size was raised, well above the limit
  161. imposed by term's N_PACKETS/2=16, (b) there was an option to turn off
  162. sending and checking packet checksums, and (c) larger packets were
  163. permitted when appropriate.
  164.  
  165. Also, to enhance security, it would be nice to have a term option to
  166. log all connections through the socket it monitors to a log file, or
  167. to stderr, or both.  This would allow one to see if one's term
  168. connection is being subverted by nasty hackers on the outside insecure
  169. machine.
  170.  
  171.  
  172. * Tricks that don't seem to work
  173.  
  174. Some telnet clients and servers agree to encrypt their communications,
  175. to prevent evesdropping on the connection.  Unfortunately, the hack
  176. used above (using the network connection that the telnet client has
  177. set up while the telnet client is idle) won't work in that case.
  178. Instead, one really must go through the telnet client itself, so it
  179. can do its encryption.  It seems like that requires a simple hack to
  180. the telnet client itself, to add a command that runs a process with
  181. its stdin and stdout are connected to the live telnet connection.
  182. This would also be useful for various 'bots, so perhaps someone has
  183. already hacked it up.
  184.  
  185.  
  186. * Extra copy of IMPORTANT DISCLAIMER --- BELIEVE IT!!!
  187.  
  188. I hereby disclaim all responsibility for this hack.  If it backfires
  189. on you in any way whatsoever, that's the breaks.  Not my fault.  If
  190. you don't understand the risks inherent in doing this, don't do it.
  191. If you use this hack and it allows vicious hackers to break into your
  192. company's computers and costs you your job and your company millions
  193. of dollars, well that's just tough nuggies.  Don't come crying to me.
  194.